package com.ruoyi.controller;

import com.ruoyi.entity.Test;
import com.ruoyi.service.impl.TestServiceImpl;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController()
@RefreshScope//nacos配置文件动态刷新
@RequestMapping("/config")
public class ConfigController {
    @Value("${spring.application.name}")
    private String name;
    @Resource
    private TestServiceImpl testService;

    /**
     * 测试远程获取配置文件
     * @return
     */
    @GetMapping("/getname")
    public String getName(){
        return name;
    }

    /**
     * 获取集合列表
     * @return
     */
    @GetMapping("/getlist")
    public List<Test> getList(){
        return testService.list();
    }
}
